
var FADE_TIME = 200;

$( document ).ready( function(){
  $( ".navigationBar > li" ).hover(function() {
    //Mouse In - Function
    if($( this ).children( "a" ).hasClass( "hasSubItems" )) {
      var subMenuDiv = $( this ).children( "div" );

      subMenuDiv.css( "left", $( this ).position().left);
      subMenuDiv.fadeIn( FADE_TIME );
    }
  },function() {
    //Mouse Out - Function
    $( this ).children( "div" ).fadeOut( FADE_TIME );
  });

  $( "a.hasSubItems + div ul li" ).hover(function() {
    //Mouse In - Function
	if($( this ).children( "a" ).hasClass( "hasSubItems" )) {
		var parentSubMenuDiv = $( $( this ).parent() );
	    var thisSubMenuDiv = $( this ).children( "div" );
	
	    thisSubMenuDiv.css( "left", parentSubMenuDiv.width() + 10);
	    thisSubMenuDiv.css( "top", $( this ).position().top );
	    thisSubMenuDiv.fadeIn( FADE_TIME );
	}
  },function() {
    //Mouse Out - Function
    $( this ).children( "div" ).fadeOut( FADE_TIME );
  });
});